using System;
using System.Configuration;
using System.Web.UI;
using HelpdeskServices.Properties;

public partial class LaunchWorkFlow1 : Page
{
    private string entityId;
    private string entityName;


    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.Request.QueryString.HasKeys())
        {
            ReadQueryStringParameters();
            if (entityId != null)
            {
                ExecuteWorkFlow();
            }
        }
    }

    private void ExecuteWorkFlow()
    {
        WorkFlow workflow = new WorkFlow();

        try
        {
            workflow.LaunchWorkFlow(entityId, entityName, ConfigurationManager.AppSettings["workflow1Id"]);
            FeedbackMessageLabel.Text = UserFeedback.ErrorWhileExecutingWorkflow;
        }
        catch (Exception error)
        {
            Response.Write(error.Message);
        }
    }

    private void ReadQueryStringParameters()
    {
        entityName = Page.Request.QueryString[Resources.QueryStringParameterObjectType];
        entityId = Page.Request.QueryString[Resources.QueryStringParameterId];
    }
}